package org.cyzy.controller;

import org.cyzy.entity.Course;
import org.cyzy.service.CurriculumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课程表控制器，用于向前端提供课程数据
 */
@RestController
@RequestMapping("/api/curriculum")
public class CurriculumController {

    @Autowired
    private CurriculumService curriculumService;

    /**
     * 根据班级ID获取课程表数据
     * @param classId 班级ID
     * @return 课程列表
     */
    @GetMapping("/class/{classId}")
    public ResponseEntity<List<Course>> getClassCurriculum(@PathVariable Integer classId) {
        // 修改为返回ResponseEntity包装的列表，确保正确的JSON格式
        return ResponseEntity.ok(curriculumService.getAllCoursesByClassId(classId));
    }
}